/*This file is part of WZLibCP.

 *  WZLibCP is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

 *  WZLibCP is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

 *  You should have received a copy of the GNU General Public License
    along with WZLibCP.  If not, see <http://www.gnu.org/licenses/>.
		
	Author: calc0000
*/
#include "stdafx.h"
#include "WZFileHeader.h"

#include <iostream>

namespace WZLib{
	std::string&		WZFileHeader::ident		(){return this->_ident;}
	unsigned long long&	WZFileHeader::fileSize	(){return this->_fileSize;}
	unsigned int&		WZFileHeader::fileStart	(){return this->_fileStart;}
	short&				WZFileHeader::version	(){return this->_version;}
	std::string&		WZFileHeader::copyright	(){return this->_copyright;}
	unsigned int&		WZFileHeader::versionHash	(){return this->_versionHash;}
	ctor WZFileHeader::WZFileHeader(){
		this->_ident="";
		this->_fileSize=this->_fileStart=0;
		this->_versionHash=0;
	}
	ErrorCode WZFileHeader::parse(WZLib::WZBinaryReader *reader){
		this->_ident=reader->ReadChars(4);
		this->_fileSize=reader->ReadUInt64();
		this->_fileStart=reader->ReadUInt32();
		this->_copyright=reader->ReadNullString();
		long p=reader->Position();
		reader->Position(this->_fileStart);
		this->_version=reader->ReadInt16();
		reader->Position(p);
		return Error_NoError;
	}
};